//* boost::any_cast<T> to pointer
#include <boost/any.hpp>
#include <iostream>
 
int main()
{
    try{
        boost::any a = 12;
        int *i = boost::any_cast<int>(&a); //convert int*
        //*long *i = boost::any_cast<long>(&a); //*result in access violation, can't be caught
        std::cout << *i << std::endl;
    }
    catch (boost::bad_any_cast &e) { //*derived from std::bad_cast
        std::cerr << e.what() << std::endl;
    }
}